package 双指针;

public class test6 {

    public int[] twoSum(int[] price, int target) {
        // 两边往中间缩进,小于target左边进,大于右边进
        int left=0,right = price.length-1;
        while (left<right){
            if(price[left]+price[right]==target)
                return new int[]{price[left],price[right]};
            else if (price[left]+price[right]>target)
                right--;
            else
                left++;
        }
        return new int[]{0};
    }
}
